# Huawei Technologies Co.,Ltd.

set(YIELDSTAR_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/yieldstar.txt)
set(YIELDSTAR_BIN ${CMAKE_CURRENT_BINARY_DIR}/yieldstar.abc)
set(YIELDSTAR_JS ${CMAKE_CURRENT_SOURCE_DIR}/yieldstar.js)
set(YIELDSTAR_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${PANDA_BINARY_ROOT}/pandastdlib/arkstdlib.abc --load-runtimes=\"ecmascript\" --compiler-enable-jit=false ${YIELDSTAR_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${YIELDSTAR_OUTPUT}
    COMMENT "running javascript yieldstar testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${YIELDSTAR_JS} --output ${YIELDSTAR_BIN}
    COMMAND rm -f ${YIELDSTAR_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} 2>&1 > ${YIELDSTAR_OUTPUT}
    COMMAND bash ${YIELDSTAR_VERIFY} ${YIELDSTAR_OUTPUT}
)
add_custom_target(yieldstar
        DEPENDS ${YIELDSTAR_OUTPUT} ${YIELDSTAR_VERIFY}
        )
add_dependencies(yieldstar ark_asm ark)
add_dependencies(ecmascript_common_tests yieldstar)
